package com.lhkj.ct.meta.modules.recycle.service;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.lhkj.ct.base.model.dto.PageQuery;
import com.lhkj.ct.base.mybatis.IBaseEntity;
import com.lhkj.ct.base.mybatis.extension.service.IPageService;
import com.lhkj.ct.meta.modules.recycle.entity.TblRecycleBin;
import org.springframework.transaction.annotation.Transactional;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Collection;
import java.util.function.Function;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author jobob
 * @since 2023-10-09
 */
public interface RecycleBinService extends IPageService<TblRecycleBin> {

    IPage<TblRecycleBin> selectRecyclePage(TblRecycleBin recycleBin, PageQuery pageQuery);

    /**
     * 删除资源
     */
    <T> int logicDelete(@NotEmpty(message = "删除编号不能为空") Collection<T> ids, @NotNull(message = "删除操作不能为空") Function<T, Integer> function);

    /**
     * 逻辑删除资源
     */
    @Transactional
    <T extends IBaseEntity<String>> int logicDeleteRealSource(@NotNull(message = "dao不能为空") BaseMapper<T> dao,
                                                              @NotBlank(message = "资源编号不能为空") String sourceId,
                                                              @NotNull(message = "idFunc不能为空") SFunction<T, ?> idFunc,
                                                              @NotNull(message = "function不能为空") SFunction<T, ?> sFunction,
                                                              @NotNull(message = "delV不能为空") Object delV,
                                                              TblRecycleBin recycleBin);

    /**
     * 恢复删除的资源
     */
    int reverse(@NotBlank(message = "恢复编号不能为空") String recycleId);

    int removeByIds(Collection<?> ids);
}
